<template>
	<view class="container">
		<u-navbar :background="{
			'backgroundColor':'transparent'
		}" title="中盈甄品油卡" :border-bottom="false" back-icon-color="#FFE1CF"
		 title-color="#FFE1CF" back-icon-name="home" :custom-back="customBack"></u-navbar>
		<view class="btn" @click="submit"></view>
		<u-image :show-loading="false" src="https://photo.hiyipin.net/USER/694024e1-7b35-446e-b63a-4e8a14bfc13d.png" mode="widthFix"
		 width="750"></u-image>

		<u-modal title="油卡提示" confirm-text="回到首页" confirm-color="#FD3129" v-model="isOpen" @confirm="$u.route({
			 url:'/pages/tabBar/newIndex/newIndex',
			 type:'tab'
		 })"
		 content="尊敬的微谷会员,检测到您已开通微谷油卡,无须再次开通了哦~"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isOpen: false
			};
		},
		onLoad(options) {
			if (options.scene) {
				let scene = decodeURIComponent(options.scene);
				let sceneArray = scene.split(',')
				if (!uni.getStorageSync('userInfo')) {
					uni.setStorageSync('proUserId', sceneArray[0])
				}
			}
		},
		onShow() {
			if (uni.getStorageSync('userInfo')) {
				this.$u.get('oilcardopenorder/checkUserOilCardIsOpen').then(res => {
					this.isOpen = res.OilCardIsOpen
				})
			}
		},
		methods: {
			customBack() {
				this.$u.route({
					url: '/pages/tabBar/newIndex/newIndex',
					type: 'tab'
				})
			},
			submit() {
				if (!uni.getStorageSync('userInfo')) {
					this.$u.route('/pages/user/login/login')
					return
				}
				this.$u.get('oilcardopenorder/openOilCardMoney').then(res => {
					this.$u.route('/pages/purchase/pay/pay', {
						money: res.earnestMoney,
						scene: 'oil'
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #080810;
		padding-bottom: 30rpx;
	}

	.container {
		position: relative;

		.btn {
			position: absolute;
			width: 540rpx;
			height: 88rpx;
			bottom: 67rpx;
			z-index: 1;
			left: 50%;
			transform: translateX(-50%);
		}
	}
</style>
